package com.component.api.model.param;

import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.setting.Setting;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 描述：
 * 组件外置属性
 * @author xianggj
 * @Date 2021/11/25 13:58
 **/
@Data
@NoArgsConstructor
public class ComponentProperties implements Serializable {

    private static final long serialVersionUID = -1L;

    private static final String ID = "component.id";
    private static final String ZH_NAME = "component.zh.name";
    private static final String CODE = "component.code";
    private static final String GROUP_ID = "component.group.id";
    private static final String SORT = "component.sort";
    private static final String CLASS_NAME = "component.class.name";
    private static final String TYPE = "component.type";
    private static final String PLATFORM = "component.platform";
    private static final String ICON = "component.icon.class";
    private static final String RIGHT_CLICKS = "component.right.click.menu";

    private String id;

    private String zhName;

    private String code;

    private String groupId;

    private int sort;

    private String className;

    private Integer type;

    private String platform;

    private String icon;

    private String[] rightClicks;

    public ComponentProperties(Setting setting) {
        this.id = setting.getStr(ID);
        this.className = setting.getStr(CLASS_NAME);
        this.zhName = UnicodeUtil.toString(setting.getStr(ZH_NAME));
        this.code = setting.getStr(CODE);
        this.groupId = setting.getStr(GROUP_ID);
        this.sort = setting.getInt(SORT);
        this.type = setting.getInt(TYPE);
        this.platform = setting.getStr(PLATFORM);
        this.icon = setting.getStr(ICON);
        this.rightClicks = setting.getStrings(RIGHT_CLICKS);
    }
}
